'''
nltk_score.py
Nicholas Swartzendruber

This is to test ranking two words.
'''

from nltk.corpus import wordnet as wn

similars = []

word1 = 'hero'
word2 = 'batman'

synsets1 = wn.synsets(word1)
synsets2 = wn.synsets(word2)

group1 = [wn.synset(str(synset.name)) for synset in synsets1]
group2 = [wn.synset(str(synset.name)) for synset in synsets2]

for sseta in group1:
  for ssetb in group2:
    path_similarity = sseta.path_similarity(ssetb)
    wup_similarity = sseta.wup_similarity(ssetb)
    
    if path_similarity is not None:
      similars.append({
         'path':path_similarity,
         'wup':wup_similarity,
         'word1':sseta,
         'word2':ssetb,
         'word1_def':sseta.definition,
         'word2_def':ssetb.definition
      })
      
similars = sorted(similars, key=\
lambda item: item['path'], reverse=True)

for item in similars:
  print item['word1'], '- ', item['word1_def']
  print item['word2'], '- ', item['word2_def']
  
  print 'path similarity - ', item['path']
  print 'wup similarity - ', item['wup'], '\n'
  

